<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/function.tld" prefix="f"%>
<%@page import="railRoad.Ticket"%>

<fmt:setBundle basename="bundles.railroadOrderBundle" />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="layout/jsc/changerowcolor.js"></script>
</head>
<body>

<c:set var="tickets" value="${sessionScope['tickets']}"></c:set>
<c:if test="${not empty tickets }">

<h2 align="center"><fmt:message key="history.title"></fmt:message></h2>

	<table id="route_table" align="center">
		<thead>
			<th><fmt:message key="route.name"></fmt:message></th>
			<th><fmt:message key="history.type"></fmt:message></th>
			<th><fmt:message key="history.price"></fmt:message></th>
		</thead>
		<tbody>
			<c:set var="reserved" value="ticketType.RESERVED" />
			<c:set var="submit">
				<fmt:message key="order.confirm"></fmt:message>
			</c:set>
			<c:set var="cancel">
				<fmt:message key="order.cancel"></fmt:message>
			</c:set>
			
			<c:forEach var="ticket" items="${tickets}">
				<c:set var="type">
					<f:ticketType ticket="${ticket}" />
				</c:set>

				<tr>
					<td align="center"><f:routeName ticket="${ticket}" /></td>
					<td align="center"><fmt:message key="${type}"></fmt:message></td>
					<td align="center"><c:out value="${ticket.price}"></c:out></td>
					<c:if test="${type eq reserved}">
						<td align="center">
						<form method="GET" action="/pages/confirm.do">
							<input type="hidden" name="ticket_id" value="${ticket.ticket_id}" /> 
							<input type="submit" value="${submit}" />
						</form>
						</td>
						<td align="center">
						<form method="GET" action="/pages/cancel.do">
							<input type="hidden" name="ticket_id" value="${ticket.ticket_id}" /> 
							<input type="submit" value="${cancel}" />
						</form>
					</c:if>
				</tr>
			</c:forEach>
	</table>
	</tbody>
</c:if>


</body>
</html>